<?php

class Application_Form_Cuadros extends Sgit_Form
{

    public function init_form()
    {
         $request = Zend_Controller_Front::getInstance()->getRequest();
         $id=$request->getParam('id');
         
         $informe =     Sgit_Util_FileUpload::run('cuadros','informe');
         $unifilar =   Sgit_Util_FileUpload::run('cuadros','unifilar');
            
         
         
         $cuadro=new Zend_Form_Element_Text('cuadro');
         $cuadro->setLabel('Cuadro')
                ->addFilter('StringTrim')
                ->addValidator('StringLength', false,array(0, 50));
         $this->addElement($cuadro);
         
           
         $cuadro_espejo=new Sgit_Form_Element_Select_Cuadros('espejo');
         $cuadro_espejo->setLabel('Cuadro Espejo')
                ->addFilter('StringTrim')
                ->addValidator('StringLength', false,array(0, 50));
         $this->addElement($cuadro_espejo);
         

         $sala=new Sgit_Form_Element_Select_Salas('id_sala');
         $this->addElement($sala); 
         

         $servicio = new Sgit_Form_Element_Select_Xml('ServicioCuadro');
         $this->addElement($servicio); 
         
         $cc=new Sgit_Form_Element_Select_CC('id_cc');
         $cc->setLabel('Origen suministro');
         $this->addElement($cc); 
         

         $calibre=new Zend_Form_Element_Text('calibre');
         $calibre->setLabel('Calibre')
                ->addFilter('StringTrim')
                ->addValidator('StringLength', false,array(0, 10));
         $this->addElement($calibre);  
         
         $remota=new Zend_Form_Element_Text('remota');
         $remota->setLabel('Remota')
                ->addFilter('StringTrim')
                ->addValidator('StringLength', false,array(0, 20));
         $this->addElement($remota);  




        $files_0=new Zend_Form_Element_File($informe['name']);
       
        $files_0->setLabel('Informe')
                ->setDestination($informe['dir'])
                ->addValidator('Size', false, 31457280)
                ->setValueDisabled(true);
        $this->addElement($files_0);


        if($id){
             $options=Sgit_Util_GetFiles::run($informe['tabla'],$informe['key'],$id);
             
             if($options){
                 $files_lista0 = new Zend_Form_Element_MultiCheckbox($informe['activo']);
                 $files_lista0->setMultiOptions($options)
                    ->setLabel('Borrar Informe')
                    ->setAttrib('size',25); 
                 $this->addElement($files_lista0);
             }
         }
         
         
         $files_1=new Zend_Form_Element_File($unifilar['name']);
         $files_1->setLabel('Unifilar')
                ->setDestination($unifilar['dir'])
                ->addValidator('Size', false, 31457280)
                ->setValueDisabled(true);
         $this->addElement($files_1);


        if($id){
             $options=Sgit_Util_GetFiles::run($unifilar['tabla'],$unifilar['key'],$id);
             
             if($options){
                 $files_lista1 = new Zend_Form_Element_MultiCheckbox($unifilar['activo']);
                 $files_lista1->setMultiOptions($options)
                    ->setLabel('Borrar Unifilar')
                    ->setAttrib('size',25); 
                 $this->addElement($files_lista1);
             }
         }
         



         
	     $notas=new Zend_Form_Element_Textarea('notas');
         $notas->setLabel('Notas')
                ->setAttribs(array('rows'=>4,'cols'=>60))
                ->addFilter('StringTrim');
         $this->addElement($notas);
       
       
    
        $this->setElementDecorators($this->getDecoratorElement());
       
       
        $files_1->setDecorators($this->getDecoratorFile());
        $files_0->setDecorators($this->getDecoratorFile());

        
    }
}
